<?php

namespace App\Listeners;

use App\Events\CourseDistribution;
use App\Events\CourseIntegral;
use App\Events\CoursePaid;
use App\Events\TeacherBonus;
use App\UserCourse;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class HandleCoursePaid
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  CoursePaid  $event
     * @return void
     */
    public function handle(CoursePaid $event)
    {
        $order = $event->order;
        // 特殊商品订单处理
        if ($order->pay_status == 1) {
            event(new CourseDistribution($order));
            event(new TeacherBonus($order));
            event(new CourseIntegral($order));
        }
    }
}
